<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Class template basic_composite_logger</title>
<link rel="stylesheet" href="../../../../../../../doc/src/boostbook.css" type="text/css">
<meta name="generator" content="DocBook XSL Stylesheets V1.79.1">
<link rel="home" href="../../../index.html" title="Chapter 1. Boost.Log v2">
<link rel="up" href="../../../logging_sources.html#header.boost.log.sources.basic_logger_hpp" title="Header &lt;boost/log/sources/basic_logger.hpp&gt;">
<link rel="prev" href="../../../logging_sources.html" title="Logging sources">
<link rel="next" href="basic_co_idm45961923091184.html" title="Class template basic_composite_logger&lt;CharT, FinalT, single_thread_model, FeaturesT&gt;">
</head>
<body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF">
<table cellpadding="2" width="100%"><tr><td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../../../boost.png"></td></tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../../../logging_sources.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../logging_sources.html#header.boost.log.sources.basic_logger_hpp"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="basic_co_idm45961923091184.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
<div class="refentry">
<a name="boost.log.sources.basic_composite_logger"></a><div class="titlepage"></div>
<div class="refnamediv">
<h2><span class="refentrytitle">Class template basic_composite_logger</span></h2>
<p>boost::log::sources::basic_composite_logger — A composite logger that inherits a number of features. </p>
</div>
<h2 xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv-title">Synopsis</h2>
<div xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" class="refsynopsisdiv"><pre class="synopsis"><span class="comment">// In header: &lt;<a class="link" href="../../../logging_sources.html#header.boost.log.sources.basic_logger_hpp" title="Header &lt;boost/log/sources/basic_logger.hpp&gt;">boost/log/sources/basic_logger.hpp</a>&gt;

</span><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> CharT<span class="special">,</span> <span class="keyword">typename</span> FinalT<span class="special">,</span> <span class="keyword">typename</span> ThreadingModelT<span class="special">,</span> 
         <span class="keyword">typename</span> FeaturesT<span class="special">&gt;</span> 
<span class="keyword">class</span> <a class="link" href="basic_composite_logger.html" title="Class template basic_composite_logger">basic_composite_logger</a> <span class="special">{</span>
<span class="keyword">public</span><span class="special">:</span>
  <span class="comment">// types</span>
  <span class="keyword">typedef</span> <span class="identifier">base_type</span><span class="special">::</span><span class="identifier">threading_model</span> <a name="boost.log.sources.basic_composite_logger.threading_model"></a><span class="identifier">threading_model</span><span class="special">;</span>  <span class="comment">// Threading model being used. </span>
  <span class="keyword">typedef</span> <span class="identifier">base_type</span><span class="special">::</span><span class="identifier">swap_lock</span>       <a name="boost.log.sources.basic_composite_logger.swap_lock"></a><span class="identifier">swap_lock</span><span class="special">;</span>        <span class="comment">// Lock requirement for the swap_unlocked method. </span>

  <span class="comment">// <a class="link" href="basic_composite_logger.html#boost.log.sources.basic_composite_loggerconstruct-copy-destruct">construct/copy/destruct</a></span>
  <a class="link" href="basic_composite_logger.html#idm45961923100496-bb"><span class="identifier">basic_composite_logger</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="basic_composite_logger.html#idm45961923099760-bb"><span class="identifier">basic_composite_logger</span></a><span class="special">(</span><a class="link" href="basic_composite_logger.html" title="Class template basic_composite_logger">basic_composite_logger</a> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <a class="link" href="basic_composite_logger.html#idm45961923098080-bb"><span class="identifier">basic_composite_logger</span></a><span class="special">(</span><span class="identifier">logger_base</span> <span class="special">&amp;&amp;</span><span class="special">)</span> <span class="keyword">noexcept</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_nothrow_move_constructible</span><span class="special">&lt;</span> <span class="identifier">base_type</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">value</span><span class="special">)</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> ArgsT<span class="special">&gt;</span> <span class="keyword">explicit</span> <a class="link" href="basic_composite_logger.html#idm45961923096368-bb"><span class="identifier">basic_composite_logger</span></a><span class="special">(</span><span class="identifier">ArgsT</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="basic_composite_logger.html#idm45961922621520-bb">public member functions</a></span>
  <span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span> <span class="identifier">attribute_set</span><span class="special">::</span><span class="identifier">iterator</span><span class="special">,</span> <span class="keyword">bool</span> <span class="special">&gt;</span> 
  <a class="link" href="basic_composite_logger.html#idm45961922620960-bb"><span class="identifier">add_attribute</span></a><span class="special">(</span><span class="identifier">attribute_name</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">,</span> <span class="identifier">attribute</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="basic_composite_logger.html#idm45961922683680-bb"><span class="identifier">remove_attribute</span></a><span class="special">(</span><span class="identifier">attribute_set</span><span class="special">::</span><span class="identifier">iterator</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="basic_composite_logger.html#idm45961922679856-bb"><span class="identifier">remove_all_attributes</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">attribute_set</span> <a class="link" href="basic_composite_logger.html#idm45961922678480-bb"><span class="identifier">get_attributes</span></a><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="basic_composite_logger.html#idm45961922676144-bb"><span class="identifier">set_attributes</span></a><span class="special">(</span><span class="identifier">attribute_set</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="identifier">record</span> <a class="link" href="basic_composite_logger.html#idm45961922672512-bb"><span class="identifier">open_record</span></a><span class="special">(</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> ArgsT<span class="special">&gt;</span> <span class="identifier">record</span> <a class="link" href="basic_composite_logger.html#idm45961922670336-bb"><span class="identifier">open_record</span></a><span class="special">(</span><span class="identifier">ArgsT</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="basic_composite_logger.html#idm45961923105648-bb"><span class="identifier">push_record</span></a><span class="special">(</span><span class="identifier">record</span> <span class="special">&amp;&amp;</span><span class="special">)</span><span class="special">;</span>
  <span class="keyword">void</span> <a class="link" href="basic_composite_logger.html#idm45961923102912-bb"><span class="identifier">swap</span></a><span class="special">(</span><a class="link" href="basic_composite_logger.html" title="Class template basic_composite_logger">basic_composite_logger</a> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>

  <span class="comment">// <a class="link" href="basic_composite_logger.html#idm45961923093840-bb">protected member functions</a></span>
  <span class="identifier">FinalT</span> <span class="special">&amp;</span> <a class="link" href="basic_composite_logger.html#idm45961923093264-bb"><span class="identifier">assign</span></a><span class="special">(</span><span class="identifier">FinalT</span> <span class="keyword">const</span> <span class="special">&amp;</span><span class="special">)</span><span class="special">;</span>
<span class="special">}</span><span class="special">;</span></pre></div>
<div class="refsect1">
<a name="idm46846464575488"></a><h2>Description</h2>
<p>The composite logger is a helper class that simplifies feature composition into the final logger. The user's logger class is expected to derive from the composite logger class, instantiated with the character type, the user's logger class, the threading model and the list of the required features. The former three parameters are passed to the <code class="computeroutput"><a class="link" href="basic_logger.html" title="Class template basic_logger">basic_logger</a></code> class template. The feature list must be an MPL type sequence, where each element is a unary MPL metafunction class, that upon applying on its argument results in a logging feature class that derives from the argument. Every logger feature provided by the library can participate in the feature list. </p>
<div class="refsect2">
<a name="idm46846464572848"></a><h3>
<a name="boost.log.sources.basic_composite_loggerconstruct-copy-destruct"></a><code class="computeroutput">basic_composite_logger</code> 
        public
       construct/copy/destruct</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><a name="idm45961923100496-bb"></a><span class="identifier">basic_composite_logger</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>Default constructor (default-constructs all features) </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idm45961923099760-bb"></a><span class="identifier">basic_composite_logger</span><span class="special">(</span><a class="link" href="basic_composite_logger.html" title="Class template basic_composite_logger">basic_composite_logger</a> <span class="keyword">const</span> <span class="special">&amp;</span> that<span class="special">)</span><span class="special">;</span></pre>
<p>Copy constructor </p>
</li>
<li class="listitem">
<pre class="literallayout"><a name="idm45961923098080-bb"></a><span class="identifier">basic_composite_logger</span><span class="special">(</span><span class="identifier">logger_base</span> <span class="special">&amp;&amp;</span> that<span class="special">)</span> <span class="keyword">noexcept</span><span class="special">(</span><span class="identifier">boost</span><span class="special">::</span><span class="identifier">is_nothrow_move_constructible</span><span class="special">&lt;</span> <span class="identifier">base_type</span> <span class="special">&gt;</span><span class="special">::</span><span class="identifier">value</span><span class="special">)</span><span class="special">)</span><span class="special">;</span></pre>
<p>Move constructor </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> ArgsT<span class="special">&gt;</span> <span class="keyword">explicit</span> <a name="idm45961923096368-bb"></a><span class="identifier">basic_composite_logger</span><span class="special">(</span><span class="identifier">ArgsT</span> <span class="keyword">const</span> <span class="special">&amp;</span> args<span class="special">)</span><span class="special">;</span></pre>
<p>Constructor with named parameters </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="idm46846464539056"></a><h3>
<a name="idm45961922621520-bb"></a><code class="computeroutput">basic_composite_logger</code> public member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1">
<li class="listitem">
<pre class="literallayout"><span class="identifier">std</span><span class="special">::</span><span class="identifier">pair</span><span class="special">&lt;</span> <span class="identifier">attribute_set</span><span class="special">::</span><span class="identifier">iterator</span><span class="special">,</span> <span class="keyword">bool</span> <span class="special">&gt;</span> 
<a name="idm45961922620960-bb"></a><span class="identifier">add_attribute</span><span class="special">(</span><span class="identifier">attribute_name</span> <span class="keyword">const</span> <span class="special">&amp;</span> name<span class="special">,</span> <span class="identifier">attribute</span> <span class="keyword">const</span> <span class="special">&amp;</span> attr<span class="special">)</span><span class="special">;</span></pre>
<p>The method adds an attribute to the source-specific attribute set. The attribute will be implicitly added to every log record made with the current logger.</p>
<p>

</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term"><code class="computeroutput">attr</code></span></p></td>
<td><p>The attribute factory. </p></td>
</tr>
<tr>
<td><p><span class="term"><code class="computeroutput">name</code></span></p></td>
<td><p>The attribute name. </p></td>
</tr>
</tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>A pair of values. If the second member is <code class="computeroutput">true</code>, then the attribute is added and the first member points to the attribute. Otherwise the attribute was not added and the first member points to the attribute that prevents addition. </p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm45961922683680-bb"></a><span class="identifier">remove_attribute</span><span class="special">(</span><span class="identifier">attribute_set</span><span class="special">::</span><span class="identifier">iterator</span> it<span class="special">)</span><span class="special">;</span></pre>
<p>The method removes an attribute from the source-specific attribute set.</p>
<p>


</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">it</code></span></p></td>
<td><p>Iterator to the previously added attribute. </p></td>
</tr></tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Requires:</span></p></td>
<td><p>The attribute was added with the add_attribute call for this instance of the logger. </p></td>
</tr>
<tr>
<td><p><span class="term">Postconditions:</span></p></td>
<td><p>The attribute is no longer registered as a source-specific attribute for this logger. The iterator is invalidated after removal.</p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm45961922679856-bb"></a><span class="identifier">remove_all_attributes</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>The method removes all attributes from the logger. All iterators and references to the removed attributes are invalidated. </p>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">attribute_set</span> <a name="idm45961922678480-bb"></a><span class="identifier">get_attributes</span><span class="special">(</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span></pre>
<p>The method retrieves a copy of a set with all attributes from the logger.</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>The copy of the attribute set. Attributes are shallow-copied. </p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm45961922676144-bb"></a><span class="identifier">set_attributes</span><span class="special">(</span><span class="identifier">attribute_set</span> <span class="keyword">const</span> <span class="special">&amp;</span> attrs<span class="special">)</span><span class="special">;</span></pre>
<p>The method installs the whole attribute set into the logger. All iterators and references to elements of the previous set are invalidated. Iterators to the <span class="emphasis"><em>attrs</em></span> set are not valid to be used with the logger (that is, the logger owns a copy of <span class="emphasis"><em>attrs</em></span> after completion).</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">attrs</code></span></p></td>
<td><p>The set of attributes to install into the logger. Attributes are shallow-copied. </p></td>
</tr></tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="identifier">record</span> <a name="idm45961922672512-bb"></a><span class="identifier">open_record</span><span class="special">(</span><span class="special">)</span><span class="special">;</span></pre>
<p>The method opens a new log record in the logging core.</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>A valid record handle if the logging record is opened successfully, an invalid handle otherwise. </p></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">template</span><span class="special">&lt;</span><span class="keyword">typename</span> ArgsT<span class="special">&gt;</span> <span class="identifier">record</span> <a name="idm45961922670336-bb"></a><span class="identifier">open_record</span><span class="special">(</span><span class="identifier">ArgsT</span> <span class="keyword">const</span> <span class="special">&amp;</span> args<span class="special">)</span><span class="special">;</span></pre>
<p>The method opens a new log record in the logging core.</p>
<p>

</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody>
<tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">args</code></span></p></td>
<td><p>A set of additional named arguments. The parameter is ignored. </p></td>
</tr></tbody>
</table></div></td>
</tr>
<tr>
<td><p><span class="term">Returns:</span></p></td>
<td><p>A valid record handle if the logging record is opened successfully, an invalid handle otherwise. </p></td>
</tr>
</tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm45961923105648-bb"></a><span class="identifier">push_record</span><span class="special">(</span><span class="identifier">record</span> <span class="special">&amp;&amp;</span> rec<span class="special">)</span><span class="special">;</span></pre>
<p>The method pushes the constructed message to the logging core</p>
<p>
</p>
<div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term">Parameters:</span></p></td>
<td><div class="variablelist"><table border="0" class="variablelist compact">
<colgroup>
<col align="left" valign="top">
<col>
</colgroup>
<tbody><tr>
<td><p><span class="term"><code class="computeroutput">rec</code></span></p></td>
<td><p>The log record with the formatted message </p></td>
</tr></tbody>
</table></div></td>
</tr></tbody>
</table></div>
</li>
<li class="listitem">
<pre class="literallayout"><span class="keyword">void</span> <a name="idm45961923102912-bb"></a><span class="identifier">swap</span><span class="special">(</span><a class="link" href="basic_composite_logger.html" title="Class template basic_composite_logger">basic_composite_logger</a> <span class="special">&amp;</span> that<span class="special">)</span><span class="special">;</span></pre>
<p>Thread-safe implementation of swap </p>
</li>
</ol></div>
</div>
<div class="refsect2">
<a name="idm46846464446480"></a><h3>
<a name="idm45961923093840-bb"></a><code class="computeroutput">basic_composite_logger</code> protected member functions</h3>
<div class="orderedlist"><ol class="orderedlist" type="1"><li class="listitem">
<pre class="literallayout"><span class="identifier">FinalT</span> <span class="special">&amp;</span> <a name="idm45961923093264-bb"></a><span class="identifier">assign</span><span class="special">(</span><span class="identifier">FinalT</span> <span class="keyword">const</span> <span class="special">&amp;</span> that<span class="special">)</span><span class="special">;</span></pre>
<p>Assignment for the final class. Threadsafe, provides strong exception guarantee. </p>
</li></ol></div>
</div>
<div class="refsect2">
<a name="idm46846464436864"></a><h3>Specializations</h3>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem"><p><a class="link" href="basic_co_idm45961923091184.html" title="Class template basic_composite_logger&lt;CharT, FinalT, single_thread_model, FeaturesT&gt;">Class template basic_composite_logger&lt;CharT, FinalT, single_thread_model, FeaturesT&gt;</a></p></li></ul></div>
</div>
</div>
</div>
<table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr>
<td align="left"></td>
<td align="right"><div class="copyright-footer">Copyright © 2007-2021 Andrey Semashev<p>
        Distributed under the Boost Software License, Version 1.0. (See accompanying
        file LICENSE_1_0.txt or copy at <a href="http://www.boost.org/LICENSE_1_0.txt" target="_top">http://www.boost.org/LICENSE_1_0.txt</a>).
      </p>
</div></td>
</tr></table>
<hr>
<div class="spirit-nav">
<a accesskey="p" href="../../../logging_sources.html"><img src="../../../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../../../logging_sources.html#header.boost.log.sources.basic_logger_hpp"><img src="../../../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../../../index.html"><img src="../../../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="basic_co_idm45961923091184.html"><img src="../../../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>
